<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>芯佑电商_修改资料</title>
    <#include "/website/commonWebsite.html">
    <!--==选择框==-->
    <link href="/website/js/checkbox/checkbox.css" rel="stylesheet" type="text/css" />
    <script src="/website/js/checkbox/checkbox.js"></script>
</head>
<body>

<!--==头部==-->
<div class="header">
    <#include "/website/header.html">
</div>

<!--==内容区域==-->
<div class="home_n">
    <div  class="home_nr">
        <!--==banner==-->
        <div class="medat-ba">会员中心</div>
        <!--==内容==-->
        <div class="medat-nr">
            <!--==左侧==-->
            <#include "/website/left.html">
            <!--==右侧==-->
            <div class="medat-nr-ri">
                <!--标题-->
                <div class="medat-nr-rib">修改资料</div>
                <!--中间信息-->
                <div class="memod-sr">
                    <div class="memod-sr-b">
                        <h1>您的头像：</h1>
                        <input type="hidden" id="imagePath" value="${user.avatar}">
                        <#if user.avatar?? && user.avatar!=''>
                            <dd style="width: 200px;"><img src="//${user.avatar}" width="40" height="40"></dd>
                        <#else>
                            <img src="/website/images/top_03.png" width="40" height="40">
                        </#if>
                        <h3 class="layui-upload" style="width: 100%;"><a href="javascript:void(0);" id="upload">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;点击修改</a></h3>
                    </div>
                    <div class="memod-sr-b">
                        <h1>您的昵称：</h1>
                        <p><input type="text" placeholder="请输入您的昵称" value="${user.name}" id="name"></p>
                    </div>
                    <div class="memod-sr-b">
                        <h1>您的性别：</h1>
                        <div class="shoinf-rad-x">
                            <label class="radio_color"><input <#if user.sex=='1'>checked</#if> type="radio" name="sex" value="1" checked>男</label>
                            <label class="radio_color"><input <#if user.sex=='2'>checked</#if> type="radio" name="sex" value="2" >女</label>
                            <label class="radio_color"><input <#if user.sex=='3'||user.sex==null||user.sex=="">checked</#if> type="radio" name="sex" value="3">保密</label>
                        </div>
                    </div>
                    <div class="memod-sr-b">
                        <h1>您的邮箱：</h1>
                        <p><input type="text" placeholder="请输入邮箱" value="${user.email}" id="email"></p>
                    </div>
                    <!--<div class="memod-sr-b">
                        <h1>手机号码：</h1>
                        <p><input type="text" placeholder="请输入手机号" value="${user.phone}" id="phone"></p>
                    </div>-->
                    <div class="memod-sr-n">
                        <span><button type="button" onclick="save()">保存</button></span>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<!--==版权==-->
<script type="text/javascript">
    function load_home() {
        document.getElementById("viewDiv").innerHTML = '';
    }
</script>
<object type="text/html" data="/website/copyright" width="100%" height="370px" style="margin-bottom: -5px;"></object>

<!--==返回头部==-->
<script type="text/javascript" src="/website/js/backtop.js"></script>

<!--==省市区==-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script src="/website/js/address/area.js"></script>
<script src="/website/js/address/select.js"></script>
</body>
<script>
    layui.use(['form', 'layedit', 'laydate','upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , upload = layui.upload;
        form.render();

        //单图片上传
        upload.render({
            elem: '#upload'
            ,url: '/aliOSS/fileUpload'
            ,data: {type: '头像'}
            ,before: function(obj){
            }
            ,done: function(res){
                if(res.success){
                    $(".memod-sr-b img").attr("src","//"+res.data[0].path);
                    $("#imagePath").val(res.data[0].path);
                }
                layer.msg(res.message)
            }
            ,error: function(){
                //演示失败状态，并实现重传
                layer.msg("未知异常");
            }
        });
        $('.layui-upload-file').hide();
    });

    //保存
    function save(){
        $.ajax({
            url:'/website/personalData/updatePersonaInfo',
            data:{
                'pk':"${user.pk}"
                ,'avatar': $("#imagePath").val()
                ,'sex':$("input[name='sex']:checked").val()
                ,'name':$("#name").val()
                ,'email':$("#email").val()
            },
            dataType:'json',
            type:'post',
            success:function(obj){
                if(obj.code==200){
                    loginout();
                }else{
                    layer.msg(obj.message);
                }
            },
            error:function(){
                layer.msg("未知错误")
            }
        })
    }
</script>

</html>